<!--内容赋值-->
<?php
$this->title="有试吗-有事没事来试试";
$conId = Yii::$app->controller->id;
use services\models\OrderInfoDetail;
?>

<!--加载样式-->
<?php $this->beginBlock('css');?>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="<?=Yii::getAlias('@static')?>/wap/liketry/css/user.css">
<style>
    .king_box_btns span{color: #666;}
</style>
<?php $this->endBlock();?>
<!--开始头部-->
	<header>
	  <div class="header-left" onclick="history.go(-1)"><span class="icon icon-arrow-left"></span></div>
      <h1>订单详情</h1>
      <div class="header-right" onclick="$.go('<?=Yii::$app->urlManager->createUrl(['index'])?>');" ><span class="icon icon-home"></span></div>
    </header>
	<ul class="order-detail user-order">
        <?php if($orderInfo) :?>
        <li class="order-num">
            <p>订单号: <span><?=$orderInfo->order_sn ?></span></p>
            <p>下单时间: <span><?=$orderInfo->create_time ?></span></p>
            <p class="staus">
                <?php if(OrderInfoDetail::$STATUS_ORDER_CREATED==$orderInfo->status) :?>
                    <?php if(strtotime($orderInfo->create_time)- strtotime("-12 hours")>0) :?>
                        <?php if($orderInfo->pay_status==OrderInfoDetail::$PAY_STATUS_WAIT) :?>
                            待付款
                        <?php elseif ($orderInfo->pay_status == OrderInfoDetail::$PAY_STATUS_CANCEL): ?>
                            已取消
                        <?php endif;?>
                    <?php else :?>
                        已取消
                    <?php endif;?>
                <?php elseif (OrderInfoDetail::$STATUS_PAYED == $orderInfo->status): ?>
                    待发货
                <?php elseif (OrderInfoDetail::$STATUS_CONFIRM == $orderInfo->status): ?>
                    待收货
                <?php elseif (OrderInfoDetail::$STATUS_TO_SHIP == $orderInfo->status): ?>
                    待收货
                <?php elseif (OrderInfoDetail::$STATUS_SIGN_IN == $orderInfo->status): ?>
                    待收货
                <?php elseif (OrderInfoDetail::$STATUS_ORDER_OK == $orderInfo->status): ?>
                    <?php if ($orderGoods['flg'] == OrderInfoDetail::$STATUS_COMMENT_NO): ?>
                        待评论
                    <?php else:?>
                        已完成
                    <?php endif; ?>

                <?php elseif (OrderInfoDetail::$STATUS_ORDER_CANCEL == $orderInfo->status): ?>
                    已取消
                <?php endif ;?>
            </p>
            <?php if(OrderInfoDetail::$STATUS_ORDER_CREATED==$orderInfo->status && strtotime($orderInfo->create_time)- strtotime("-2 hours")>0 && $orderInfo->pay_status==OrderInfoDetail::$PAY_STATUS_WAIT ) :?>
            <p id="orderCutDown" class="countdown" data="<?php echo strtotime($orderInfo->create_time)- strtotime("-12 hours");?>">剩余时间: <span></span></p><!--未支付倒计时-->
            <?php endif;?>
        </li>
        <li class="order-peo">
            <p><?=$orderInfo->lgistics->consignee ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?=$orderInfo->lgistics->mobile_phone ?></p>
            <p><?=$orderInfo->lgistics->province ?>&nbsp;&nbsp;&nbsp;<?=$orderInfo->lgistics->city ?>&nbsp;&nbsp;&nbsp;<?=$orderInfo->lgistics->county ?>&nbsp;&nbsp;&nbsp;<?=$orderInfo->lgistics->address ?></p>
        </li>
        <li class="order-img">
            <p>商品清单</p>
            <a class="view-all" href="<?=Yii::$app->urlManager->createUrl(["{$conId}/comreviews",'order_info_id'=>$orderInfo->order_info_id]);?>">查看全部<span><?=$orderGoodsNUM?></span>件商品<i class="icon-arrow-right"></i></a>
            <div class="img-list ">
                <?php if(count($orderGoods['data'])>0) :?>
                    <?php foreach($orderGoods['data'] as$key=> $val) :?>
                        <?php if($key < 4):?>
                        <div class="box-sizing">
                        <a href="<?=Yii::$app->urlManager->createUrl(["{$conId}/comreviews",'order_info_id'=>$orderInfo->order_info_id]);?>"><img src="<?php if($val['goodPic']['pic'] !='') :?>
                        <?=Yii::$app->params['goods_image_url'].str_replace('./upload', 'upload', $val['goodPic']['pic'])?><?php endif;?>" /></a>
                        <p>X <?=$val['buy_number']?></p></div>
                        <?php endif ;?>
                    <?php endforeach ;?>
                <?php endif;?>
            </div>
        </li>
        <li class="order-pay">
            <p>支付方式</p>
            <?php ?>
            <p><?=$orderInfo->pay_name ?></p>
        </li>
        <li class="order-price">
            <p>商品金额
                <span>
                    <?php if($orderInfo->goods_amount !=0):?>￥<?=Yii::$app->formatter->asDecimal($orderInfo->goods_amount,2)?><?php endif;?>
                    <?php if($orderInfo->goods_amount !=0 && $orderInfo->try_coin !=0):?>+<?php endif;?>
                    <?php if($orderInfo->try_coin !=0):?><?=$orderInfo->try_coin ?>试豆<?php endif;?>
                </span>
            </p>
            <p>邮&nbsp;&nbsp;&nbsp;&nbsp;费
                <span>
                    <?php if($orderInfo->ship_amount_try_coin !=0):?>
                        <?=$orderInfo->ship_amount_try_coin?>试豆
                    <?php else:?>
                        <?php if($orderInfo->ship_amount !=0):?>
                        ¥<?=Yii::$app->formatter->asDecimal($orderInfo->ship_amount,2)?>
                        <?php else :?>
                        ¥0.00
                        <?php endif;?>
                    <?php endif;?>
                </span>
            </p>
            <p>余额支付<span> -￥<?=Yii::$app->formatter->asDecimal($orderInfo->member_money,2)?></span></p>
            <p>优惠金额<span>-￥<?=Yii::$app->formatter->asDecimal($orderInfo->reduce_amount+$orderInfo->coupon_amount,2)?></span></p>
        </li>
        <li class="order-total">
            <p>合计:
                <span>
                    <?php if($orderInfo->order_amount !=0):?>￥<?=Yii::$app->formatter->asDecimal($orderInfo->order_amount,2)?><?php endif;?>
                    <?php if($orderInfo->order_amount !=0 && $orderInfo->try_coin !=0):?>+<?php endif;?>
                    <?php if($orderInfo->try_coin !=0):?><?=$orderInfo->try_coin ?>试豆<?php endif;?>
                </span>
            </p>
            <?php if ($orderInfo->status == OrderInfoDetail::$STATUS_ORDER_CREATED): ?>
                <?php if($orderInfo->pay_status ==OrderInfoDetail::$PAY_STATUS_WAIT && (strtotime($orderInfo->create_time)- strtotime("-12 hours"))>0):?>
                    <div class="btn">
                        
                        <!--订单操作按钮 Start-->
                        <a href="<?=Yii::$app->urlManager->createUrl(["order/success",'order_info_id'=>$orderInfo->order_info_id]);?>">立即付款</a>
                        <a class=" cancel" data-url="<?=Yii::$app->urlManager->createUrl(["{$conId}/cancel-order",'order_info_id'=>$orderInfo->order_info_id])?>">取消订单</a>
                        <!--订单操作按钮 End-->
                    </div>
                <?php endif ;?>
            <?php elseif (OrderInfoDetail::$STATUS_PAYED == $orderInfo->status): ?>
                <div class="btn">
                    <!--订单操作按钮 Start-->
                    <a class="cancel" data-url="<?=Yii::$app->urlManager->createUrl(["{$conId}/cancel-order",'order_info_id'=>$orderInfo->order_info_id])?>">取消订单</a>
                    <!--订单操作按钮 End-->
                </div>
            <?php elseif (in_array($orderInfo->status,OrderInfoDetail::$STATUS_IN_KEY)): ?>
                <div class="btn">
                    <a class="getGoods" data-href="<?=Yii::$app->urlManager->createUrl(["{$conId}/sure-order",'order_info_id'=>$orderInfo->order_info_id])?>">确认收货</a>
                    <a class="shaidan" style="display:none">评论晒单</a>
                    <a href="<?=Yii::$app->urlManager->createUrl(["{$conId}/logic",'order_info_id'=>$orderInfo->order_info_id])?>">查看物流</a>
                </div>
            <?php elseif(OrderInfoDetail::$STATUS_ORDER_OK == $orderInfo->status) : ?>
                <?php if ($orderGoods['flg'] == OrderInfoDetail::$STATUS_COMMENT_NO): ?>
                    <div class="btn">
                        
                        <a class="shaidan">评论晒单</a>
                        <a href="<?=Yii::$app->urlManager->createUrl(["{$conId}/logic",'order_info_id'=>$orderInfo->order_info_id])?>">查看物流</a>
                    </div>
                <?php endif ;?>
            <?php endif ;?>
        </li>

        <?php else :?>
            暂无订单信息！
        <?php endif ;?>
	</ul>


<!--加载js-->
<?php $this->beginBlock('js');?>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/zepto.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/fastclick.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/common/js/king.wap.js"></script>
<script src="<?=Yii::getAlias('@static')?>/wap/liketry/js/order-detail.js"></script>
<?php $this->endBlock();?>
